#@embedLayout()


#define content()

<form id="policyConfigFormId" method="post">
    <input type="hidden" name="policyConfigId" id="venId" value="#(policyConfigId??)">
    <table class="table table-bordered">
        <tr>
            <td>参数名称:</td>
            <td>
                <a href="javascript:void(0);"
                   title="#(_res.get(policyConfigName))"
                   class="easyui-tooltip"
                   id="policyConfigName">#(policyConfigName??)</a>
            </td>
        </tr>
        <tr>
            <td>参数内容:</td>
            <td>
                #if(policyConfigDataType == 'boolean')
                <select name="policyConfigValue" id="policyConfigValue" >
                    <option value="true" #(policyConfigValue?? == 'true' ? 'selected':'')>true</option>
                    <option value="false" #(policyConfigValue?? == 'false'  ? 'selected':'')>false
                    </option>
                </select>


                #elseif(policyConfigDataType == 'string')
                <input type="text" class="easyui-textbox" id="policyConfigValue" name="policyConfigValue"
                       data-options="required:true,validType:{length:[1,256]}"
                       value="#(policyConfigValue??)">


                #elseif(policyConfigDataType == 'json')
                <select name="policyConfigValue" id="policyConfigValue" >

                    <script>

                        function isJsonString(str) {
                            try {
                                if (typeof JSON.parse(str) == "object") {
                                    return true;
                                }
                            } catch (e) {
                            }
                            return false;
                        }
                    </script>
                    <script>
                        var ob, htmlOpton=[];

                        if(('#(policyConfigName??)')==("webauthn.authenticator.selection.criteria.authenticator.attachment"))
                        {
                            ob = '["platform","cross-platform"]';
                        }else if (('#(policyConfigName??)')==("webauthn.authenticator.selection.criteria.user.verification"))
                        {
                            ob = '["required","preferred","discouraged"]';
                        }else if (('#(policyConfigName??)')==("webauthn.authenticator.selection.criteria.authenticator.attestation"))
                        {
                            ob = '["direct","indirect","none"]';
                        }

                        var optionlist =JSON.parse(ob);
                        for (var optionNode in optionlist) {
                            var htmlOptonNode = '<option value='+optionlist[optionNode]+'>'+optionlist[optionNode]+'</option>';
                            htmlOpton.push(htmlOptonNode);
                            document.getElementById("policyConfigValue").innerHTML = htmlOpton.join('');

                        }


                        var optionSet =  document.getElementById("policyConfigValue")
                        console.log("optionSet length "+','+optionSet.length);
                        if (!isJsonString('#(policyConfigValue??)'))
                        {
                            for (var optionSetIndex in optionSet)
                                if (null != optionSet[optionSetIndex] &&
                                    optionSet[optionSetIndex].value == '#(policyConfigValue??)')
                                    optionSet[optionSetIndex].selected = true;
                        }

                    </script>
                </select>


                #else
                <input type="text" class="easyui-textbox" id="policyConfigValue" name="policyConfigValue"
                       data-options="required:true,validType:{length:[1,256]}"
                       value="#(policyConfigValue??)">

                #end
            </td>
        </tr>
        <tr>
            <td>描述:</td>
            <td><input type="text" class="easyui-textbox" id="policyConfigDes" name="policyConfigDes"
                       data-options="required:true,validType:{length:[1,512]}"
                       value="#(policyConfigDes??)">
            </td>
        </tr>
    </table>
</form>

#end


#define css()


#end


#define js()

<script type="text/javascript">
    function policyConfig_datagrid_save(opr_type) {
        var url = '';
        if (opr_type === 'add') {
            url = contextRootPath + '/policy/policyConfigSave?policyId='+ '#(policyId??)';
        } else {
            url = contextRootPath + '/policy/policyConfigUpdate';
        }

        $('#policyConfigFormId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');
                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);
                var params = {};
                params.element = vendorDatagridId;
                params.data = data;
                params.dlgId = "vendor_crud_dlg";
                resultCallback(params);
            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }


</script>

#end


